Browser

A web browser control that allows loading a web page or a local HTML file, accessing DOM and executing JavaScript on the loaded web page, getting notifications about loading progress, dispatching keyboard and mouse events, etc.

The Browser instance itself is running in a separate native process that allocates memory and system resources that must be released. So, when a Browser instance is no longer needed, it must be closed through the close method to release all the allocated memory and system resources. For example:

Browser browser = engine.newBrowser();
...
browser.close();

Any attempt to use an already closed Browser instance will lead to the IllegalStateException.

The Browser instance is closed automatically when its Engine is closed or unexpectedly crashed. If the instance represents a popup window created by JavaScript via the window.open() function, then JavaScript can close the instance using the window.close() function.

To get notifications that the Browser instance has been closed please subscribe to the following event:


browser.on(BrowserClosed.class, event -> {
    // The Browser instance has been closed.
});

Properties

Link copied to clipboard

Returns the service that allows controlling audio on a currently loaded web page.

Link copied to clipboard

Returns a Bitmap that contains the image of the currently loaded web page.

Link copied to clipboard

Returns the default JavaScript PresentationRequest specified on the page.

Link copied to clipboard

Returns the service that allows working with Chromium Developer Tools.

Link copied to clipboard

Returns the display where the current browser instance is located.

Link copied to clipboard

Returns the engine instance of this Browser.

Link copied to clipboard

Returns a Bitmap that contains the favicon of the currently loaded web page or the default Chromium favicon if the browser did not load any web pages or loaded web page URL is invalid.

Link copied to clipboard

Returns the focused frame on the currently loaded web page, if any.

Link copied to clipboard

Returns all the frames on the currently loaded web page or an empty collection if the browser did not load any web pages.

Link copied to clipboard

Returns the service that controls the fullscreen mode.

Link copied to clipboard

Returns the main frame of the currently loaded web page, if any.

Link copied to clipboard
Link copied to clipboard

Returns the profile that the browser belongs to.

Link copied to clipboard
Link copied to clipboard

Returns settings that configure this Browser.

Link copied to clipboard

Returns the size of this Browser in the logical pixels.

Link copied to clipboard

Returns the service that allows searching text on a currently loaded web page.

Link copied to clipboard

Returns a string that represents the title of the currently loaded web page, or an empty string if the browser hasn't loaded any web page yet.

Link copied to clipboard

Returns a string that represents URL of the currently loaded web page, or an empty string if the browser hasn't loaded any web page yet.

Link copied to clipboard

Returns a string that represents the user-agent of this Browser.

Link copied to clipboard

Returns the service that allows zooming content of a currently loaded web page.

Functions

Link copied to clipboard
abstract fun audio(): Audio
Returns Audio that allows controlling audio on a web page loaded in the current browser instance.
Link copied to clipboard
abstract fun bitmap(): Bitmap
Returns a Bitmap that contains the image of the currently loaded web page.
Link copied to clipboard
inline fun <C : Callback> Advisable<in C>.callback(): C?
inline fun <C : Callback> Advisable<in C>.callback(): C?

Returns the currently registered callback of type C, if any.

Link copied to clipboard
Returns an immutable list of all active capture sessions initiated by the browser.
Link copied to clipboard
Starts casting the browser content to the media receiver.
Link copied to clipboard
Starts casting screen's content by selecting the screen in the picker dialog.
Starts casting the screen's content to the media receiver.
Link copied to clipboard
abstract fun close()
Closes the current browser instance and releases all allocated resources.
abstract fun close(options: CloseOptions)
Closes the current browser instance according to the given options.
abstract fun close()
Link copied to clipboard
Returns the default JavaScript PresentationRequest specified on the page.
Link copied to clipboard
abstract fun devTools(): DevTools
Returns DevTools that allows working with Chromium Developer Tools.
Link copied to clipboard
abstract fun dispatch(event: KeyPressed)
Dispatches the key pressed event to the currently focused element on the loaded web page.
abstract fun dispatch(event: KeyReleased)
Dispatches the key released event to the currently focused element on the loaded web page.
abstract fun dispatch(event: KeyTyped)
Dispatches the key typed event to the currently focused element on the loaded web page.
abstract fun dispatch(event: MouseDragged)
Dispatches the mouse dragged event to the currently loaded web page.
abstract fun dispatch(event: MouseEntered)
Dispatches the mouse entered event to the currently loaded web page.
abstract fun dispatch(event: MouseExited)
Dispatches the mouse exited event to the currently loaded web page.
abstract fun dispatch(event: MouseMoved)
Dispatches the mouse moved event to the currently loaded web page.
abstract fun dispatch(event: MousePressed)
Dispatches the mouse pressed event to the currently loaded web page.
abstract fun dispatch(event: MouseReleased)
Dispatches the mouse released event to the currently loaded web page.
abstract fun dispatch(event: MouseWheel)
Dispatches the mouse wheel event to the currently loaded web page.
Link copied to clipboard
abstract fun display(): Display
Returns the display where the current browser instance is located.
Link copied to clipboard
abstract fun engine(): Engine
Returns the engine instance of the current browser.
Link copied to clipboard
abstract fun favicon(): Bitmap
Returns a Bitmap that contains the favicon of the currently loaded web page or a Bitmap that contains default Chromium favicon if the browser did not load any web pages or loaded web page URL is invalid.
Link copied to clipboard
abstract fun focus()
Tells the current browser instance that it has focus and must be activated.
Link copied to clipboard
abstract fun focusedFrame(): Optional<Frame>
Returns an Optional that contains the focused Frame on the currently loaded web page, otherwise an empty Optional.
Link copied to clipboard
abstract fun frames(): List<Frame>
Returns all the frames on the currently loaded web page or an empty collection if the current browser did not load any web pages.
Link copied to clipboard
abstract fun fullScreen(): FullScreen
Returns the service that controls the fullscreen mode.
Link copied to clipboard
abstract fun <C : P?> get(callbackClass: Class<C>): Optional<C>
Returns an Optional that contains the callback of the given type or an empty Optional if there is no registered callback with the given type.
Link copied to clipboard
abstract fun isClosed(): Boolean
Returns true if the current object is closed.
Link copied to clipboard
abstract fun mainFrame(): Optional<Frame>
Returns an Optional that contains the main Frame of the currently loaded web page if it exists, otherwise an empty Optional.
Link copied to clipboard
abstract fun navigation(): Navigation
Returns Navigation that allows controlling navigation in the current browser instance.
Link copied to clipboard
abstract fun <E : T?> on(eventClass: Class<E>, observer: Observer<E>): Subscription
Subscribes the given event observer to receive the events of the given eventClass.
Link copied to clipboard
abstract fun profile(): Profile
Returns the profile that the browser belongs to.
Link copied to clipboard
inline fun <C : Callback> Advisable<in C>.register(callback: C): C?
inline fun <C : Callback> Advisable<in C>.register(callback: C): C?

Registers the given callback in this Advisable.

Link copied to clipboard
abstract fun <C : P?> remove(callbackClass: Class<C>): C
Removes a particular service callback.
Link copied to clipboard
inline fun <C : Callback> Advisable<in C>.removeCallback(): C?
inline fun <C : Callback> Advisable<in C>.removeCallback(): C?

Removes a callback of type C from this Advisable, if any.

Link copied to clipboard
abstract fun replaceMisspelledWord(word: String)
Replaces misspelled word under cursor on the currently loaded web page with the given word.
Link copied to clipboard
abstract fun resize(size: Size)
Updates size of the current browser instance with the given one.
abstract fun resize(width: Int, height: Int)
Updates size of this Browser instance with the given width and height.
Link copied to clipboard
abstract fun saveWebPage(htmlFilePath: Path, resourcesDir: Path, saveType: SavePageType): Boolean
Initiates the saving process of the currently loaded web page.
Link copied to clipboard
abstract fun <C : P?> set(callbackClass: Class<C>, callback: C): C
Sets a particular service callback.
Link copied to clipboard
abstract fun settings(): BrowserSettings
Returns BrowserSettings that allows configuring the current browser instance.
Link copied to clipboard
abstract fun size(): Size
Returns the size of the current browser instance in the logical pixels.
Link copied to clipboard
inline fun <E : Event> Observable<in E>.subscribe(observer: Observer<E>): Subscription
inline fun <E : Event> Observable<in E>.subscribe(observer: Observer<E>): Subscription

Subscribes the given observer to receive events of type E from this Observable.

Link copied to clipboard
abstract fun textFinder(): TextFinder
Returns TextFinder that allows finding text on a web page loaded in the current browser instance.
Link copied to clipboard
abstract fun title(): String
Returns a string that represents the title of the currently loaded web page or an empty string if the browser hasn't loaded any web page yet.
Link copied to clipboard
abstract fun unfocus()
Tells the current browser instance that it does not have focus and must be deactivated.
Link copied to clipboard
abstract fun url(): String
Returns a string that represents URL of the currently loaded web page or an empty string if the browser hasn't loaded any web page yet.
Link copied to clipboard
abstract fun userAgent(): String
Returns a string that represents the user-agent of the current browser instance.
abstract fun userAgent(userAgent: String)
Updates the user-agent string of the current browser instance and reloads the currently loaded web page.
Link copied to clipboard
abstract fun zoom(): Zoom
Returns Zoom that allows zooming content of a web page loaded in the current browser instance.